/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.startingbsd.dao;

import br.com.startingbsd.beans.Formulario;
import java.util.List;
import javax.persistence.EntityManager;

/**
 *
 * @author Felipe
 */
public class FormularioDAO extends BaseDAO{
    
    public static Formulario getFormulario(long id){
        EntityManager em = getEntityManager();
        Formulario u = (Formulario) em.createQuery("select m from formulario m where m.id = "+id).getSingleResult();
        em.close();
        return u;
    }

   public static List<Formulario> getFormularios() {
        EntityManager em = getEntityManager();
        List<Formulario> u = em.createQuery("select m from formulario m").getResultList();
        em.close();
        return u;
    }
   
   public static List<Formulario> getFormularios(long id_usuario) {
        EntityManager em = getEntityManager();
        List<Formulario> u = em.createQuery("select m from formulario m where usuario = "+id_usuario).getResultList();
        em.close();
        return u;
    }
    
}
